<?php

namespace app\admin\controller;

use think\Db;
use think\Controller;
use think\Session;

class Login extends Controller
{
    public function index()
    {
       return $this->fetch('login/index');
    }


    public function login()
    {
        $param = $this->request->param();
        $res = Db::table('admin')->where('login_number',$param['login_number'])->find();
        if(!empty($res)){
            if($res['password'] == md5($param['password'])){
                Session::set('admin_info',$res);
                return json(['code'=>200,'msg'=>'登录成功']);
            }else{
                return json(['code'=>400,'msg'=>'账号或者密码错误']);
            }
        }else{
            return json(['code'=>400,'msg'=>'账号或者密码错误']);
        }
    }

}